package com.rxh.controller;

import com.rxh.exception.PayException;
import com.rxh.pojo.Result;
import com.rxh.pojo.cross.BankResult;
import com.rxh.service.PaymentNotifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created with IntelliJ IDEA.
 * User: 陈俊雄
 * Date: 2018/10/18
 * Time: 9:48
 * Project: Management
 * Package: com.rxh.controller
 */
@Controller
public class PaymentNotifyController {
    private final PaymentNotifyService paymentNotifyService;

    @Autowired
    public PaymentNotifyController(PaymentNotifyService paymentNotifyService) {
        this.paymentNotifyService = paymentNotifyService;
    }

    @RequestMapping("/bankNotify")
    @ResponseBody
    public Result bankNotify(@RequestBody BankResult bankResult) throws PayException {
        return paymentNotifyService.updateOrderAndDoNotify(bankResult);
    }
}
